<?php
/**
 * Copyright (C), 2021-2021, Shall Buy Life info. Co., Ltd.
 * FileName: UserRequest.php
 * Description: 说明
 *
 * @author lwl
 * @Create Date    2021/10/9 15:29
 * @Update Date    2021/10/9 15:29 By lwl
 * @version v1.0
 */

namespace App\Requests;

class UserRequest extends BaseRequest
{
    /**
     * 验证场景器
     * @var \string[][]
     */
    public $scenes = [
        'login' => ['user_name', 'password'],
        'update_password'=>['password','password_confirm']
    ];

    /**
     * FunctionName：authorize
     * Description：鉴权
     * Author：lwl
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * FunctionName：rules
     * Description：验证规则
     * Author：lwl
     * @return string[]
     */
    public function rules(): array
    {
        return self::baseRules();

    }

    /**
     * FunctionName：baseRules
     * Description：
     * Author：lwl
     * @return string[]
     */
    public static function baseRules()
    {
        return [
            'user_name' => 'required|max:10',
            'password' => 'required|max:50',
            'password_confirm'=>'required|same:password'
        ];
    }

    /**
     * FunctionName：attributes
     * Description：
     * Author：lwl
     * @return string[]
     */
    public function attributes()
    {
        return [
            'user_name' => '账号',
            'password' => '密码',
            'id' => 'ID',
            'update_password'=>'确认密码'
        ];
    }
}
